<template>
  <div class="live">
    <div class="photo">
      <p>房间名称：{{ room_name }}</p>
      <img :src="avatar" alt="" />
      <div class="photo-bottom">
        <p>
          主播：{{ owner_name }}
          <span :style="roomStatus">({{ room_status }})</span>
        </p>
        <p>直播开始时间：{{ start_time }}</p>
        <p>直播时长：{{ online }}</p>
      </div>
      <router-link to="">直播入口</router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: "detail",
  data() {
    return {
      avatar: "",
      room_id: "",
      room_name: "",
      owner_name: "",
      start_time: "",
      online: "",
      room_status: 0,
    };
  },
  created() {
    this.room_id = this.$route.params.id;
    let { title, cate_id } = this.$route.query;
    this.title = title;
    this.cate_id = cate_id * 1;
    this.axios({
      url: `/livedetail/api/RoomApi/room/${this.room_id}`,
      method: "GET",
    }).then((res) => {
      let data = res.data.data;
      this.room_name = data.room_name;
      this.owner_name = data.owner_name;
      this.start_time = data.start_time;
      this.online = data.online;
      this.avatar = data.avatar;
      this.room_status = data.room_status ? "直播中" : "未直播";
      localStorage.setItem("detailTitle", data.owner_name);
    });
  },
  computed: {
    roomStatus() {
      return {
        color: this.room_status == "直播中" ? "blue" : "red",
      };
    },
  },
};
</script>

<style lang="less" scoped>
.photo {
  padding-top: 20px;
  p {
    color: blue;
    font-size: 14px;
  }
  img {
    padding-top: 20px;
    width: 50%;
    border-radius: 50%;
  }
  .photo-bottom {
    padding: 20px 0px;
    width: 80%;
    margin: 0 auto;
    p {
      line-height: 30px;
      text-align: left;
    }
  }
  a {
    display: block;
    margin: 0px auto;
    outline: none;
    border: none;
    background-color: red;
    color: #fff;
    width: 150px;
    line-height: 35px;
    font-size: 16px;
    border-radius: 5px;
  }
}
</style>
